/**
 * @Author houlijx
 * @Description //TODO $
 * @Date 2021/8/14 下午6:25
 **/
package timeUtils

import (
	"gitee.com/go-package/carbon/v2"
	"time"
)

//GetCurrentTimeMillis
//获取当前时间毫秒树
func GetCurrentTimeMillis() int64 {
	return time.Now().UnixNano() / 1e6
}

func GetCurrentTimeSecond() int64 {
	return GetCurrentTimeMillis() / 1000
}

//GetDefaultTime
//获取默认时间字符串，格式为Y-m-d H:i:s
func GetDefaultTime() string {
	return time.Now().Format(carbon.DateTimeFormat)
}

// ParseByFormat
// 解析时间为毫秒数
func ParseByFormat(time, tpl string) int64 {
	return carbon.ParseByFormat(time, tpl).TimestampWithMillisecond()
}

func Format(timestamp int64, tpl string) string {
	return carbon.CreateFromTimestamp(timestamp).Format(tpl)
}
